﻿Public Class Departamentos
    Private ucRegistrar As New RegistrarDepartamento
    ' Private ucBuscar As New BuscarDepartamento

    Private Sub Departamentos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ubicacion As New Point(152, 0)

        ' Buscar
        ''  ucBuscar.Visible = False
        ''  ucBuscar.Location = ubicacion

        ' Registrar
        ucRegistrar.Visible = False
        ucRegistrar.Location = ubicacion

        ' Agrega los controles
        ''  Me.Controls.Add(ucBuscar)
        Me.Controls.Add(ucRegistrar)
    End Sub

    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        Select Case e.Node.Name
            Case "ndBuscar"
                ''     mostrarConfig(ucBuscar)
            Case "ndRegistrar"
                mostrarConfig(ucRegistrar)
        End Select
    End Sub

    Private Sub mostrarConfig(ByVal p_uc As UserControl)
        'Escondemos todas las pantallas de configuración
        For Each uc As Control In Me.Controls
            If TypeOf uc Is UserControl Then
                uc.Visible = False
            End If
        Next

        'Mostramos la que se pidió
        p_uc.Visible = True
    End Sub
End Class
